<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('department_id')->default(0)->comment('用户所属部门');
            $table->string('username')->default('')->comment('用户名');
            $table->string('realname')->default('')->comment('真实姓名');
            $table->string('password')->default('')->comment('密码');
            $table->tinyInteger('status')->default(10)->comment('用户状态');
            $table->timestamp('last_login_at')->nullable()->comment('最后一次登录时间');
            $table->string('avatar')->default('')->comment('用户头像');
            $table->timestamps();
            $table->softDeletes();

            $table->index('department_id');
            $table->index('status');
            $table->index('username');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user');
    }
}
